Skip to content
This repository has been archived by the owner on Dec 5, 2019. It is now read-only.

Use strpos (much faster than preg_match) to determine if a char is a white space #327

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

mlocati
Copy link
Contributor

@mlocati mlocati commented Sep 2, 2016

What about using strpos instead of the slower preg_match?

White space characters are defined by the PCRELib as:

  • LF (dec 10 = hex \x0a = char "\n")
  • HT (dec 9 = hex \x09 = char "\t")
  • VT (dec 11 = hex \x0b = char "\v")
  • FF (dec 12 = hex \x0c = char "\f")
  • CR (dec 13 = hex \x0d = char "\r")
  • space (dec 32 = hex \x20 = char " ")

…white space

White space characters are defined by the PCRELib as:
- LF (dec 10 = hex \x0a = char "\n")
- HT (dec 9 = hex \x09 = char "\t")
- VT (dec 11 = hex \x0b = char "\v")
- FF (dec 12 = hex \x0c = char "\f")
- CR (dec 13 = hex \x0d = char "\r")
- space (dec 32 = hex \x20 = char " ")

Reference:
https://github.com/php/php-src/blob/master/ext/pcre/pcrelib/doc/pcre.txt#L5203-L5204
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant